package com.ikun.util;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResultCode {

    public static final ResultCode SUCCESS = dealResult(ResultCodeEnum.SUCCESS);
    public static final ResultCode ERROR = dealResult(ResultCodeEnum.ERROR);
    public static final ResultCode TIMEOUT = dealResult(ResultCodeEnum.NETWORK_TIMEOUT);
    public static final ResultCode FILE_TYPE_ERROR = dealResult(ResultCodeEnum.FILE_TYPE_ERROR);
    public static final ResultCode FILE_OUT_MAX = dealResult(ResultCodeEnum.FILE_OUT_MAX);
    private int code;
    private String msg;

    private static ResultCode dealResult(ResultCodeEnum codeEnum) {
        return ResultCode.builder().code(codeEnum.getCode()).msg(codeEnum.getMsg()).build();
    }

}
